//
//  RetrieveViewController.m
//  Four_Fit_New
//
//  Created by xalo on 16/7/18.
//  Copyright © 2016年 xmaz. All rights reserved.
//

#import "RetrieveViewController.h"
#import "LoginViewController.h"
#import "RetrieveModel.h"


/**
 *  找回密码
 */

@interface RetrieveViewController ()<UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UITextField *idTextField;
@property (weak, nonatomic) IBOutlet UITextField *passwordTextField;
@property (weak, nonatomic) IBOutlet UITextField *validataTextField;
@property (weak, nonatomic) IBOutlet UIButton *mationBtn;


@end

@implementation RetrieveViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.idTextField.clearsOnBeginEditing = YES;
    self.validataTextField.clearsOnBeginEditing = YES;
    self.idTextField.returnKeyType = UIReturnKeyNext;
    self.idTextField.returnKeyType = UIReturnKeyNext;
    self.validataTextField.keyboardType = UIKeyboardTypeNumberPad;
    
    
    self.passwordTextField.delegate = self;
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"Unknown-1.png"] style:(UIBarButtonItemStylePlain) target:self action:@selector(leftAction:)];
    
}

- (void)leftAction:(UIBarButtonItem *)sender {
    
    [self dismissViewControllerAnimated:YES completion:nil];
}
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
    
    self.passwordTextField.clearsOnBeginEditing = YES;
    return YES;
    
}
-(void)textFieldDidBeginEditing:(UITextField *)textField{
    
    
    if ((self.passwordTextField.clearsOnBeginEditing = YES)) {
        
        self.passwordTextField.secureTextEntry = YES;
    }
}
//获取验证码
- (IBAction)mationBtnAction:(id)sender {
    
    [[QZRequestManager sharedManager]fetchDataWithUrl:@"http://ws.sythealth.com/wsbyte/fit/v4/sms/validatorcode?account=15135038948&form=2&tokenid=tokenid_undefined" parameters:@{@"account":self.idTextField.text} method:@"GET" needToCaches:NO fetchData:^(NSData *data) {
       
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
        NSLog(@"%@",dic);
    } updateUI:^{
        
    }];
}
//确定修改
- (IBAction)defineBtnAction:(id)sender {
    
    [[QZRequestManager sharedManager]fetchDataWithUrl:@"http://ws.sythealth.com/ws/fit/v4/user/resetpwd?account=15135038948&password=qwe110&tokenid=tokenid_undefined&validatorcode=5930" parameters:@{} method:@"GET" needToCaches:NO fetchData:^(NSData *data) {
        
        if ((self.validataTextField.text = @"validatorcode")) {
            
            NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
            NSLog(@"%@",dic);
        } else {
            
            NSLog(@"输入验证码错误");
        }
    } updateUI:^{
        
        
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
